 class maskUtil {
    constructor() {

    }
    //字符串掩码
    stringMask(oriStr, frontLen, endLen) {
        let result = oriStr;
        if (oriStr == null || oriStr.length == 0) {
            return  "";
        }
        if ((endLen + frontLen) == oriStr.length && endLen == 1) {
            result = oriStr.substring(0, frontLen) + "*";
        }
        let len = oriStr.length - frontLen - endLen;
        let maskStars = "";
        for (let i = 0 ; i < len ; i++) {
            maskStars += "*";
        }
        result = oriStr.substring(0, frontLen) + maskStars + oriStr.substring(oriStr.length - endLen);
        return  result;
    }
    realNameMask (realName) {
        if (realName == null || realName == "") {
            return  "";
        } else if (realName.length == 2) {
            return this.stringMask(realName, 0 ,1);
        } else {
            return this.stringMask(realName, 0 ,2);
        }
    }
    //手机号掩码
    phoneMask (phone) {
        return this.stringMask(phone, 3, 2);
    }
    //身份证掩码
    idNumberMask (idNumber) {
        return this.stringMask(idNumber, 1 ,1);
    }
};

var maskUtils = new maskUtil()

export default maskUtils